package com.jandar.util;

import com.jandar.entity.ExcelSourceTypeMapping;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MapTransferUtil {

//    public static Map<String, Object> transfer(Map<String, Object> map, List<Map<String, Object>> mappings) {
//        Map<String, Object> result = new HashMap<>();
//        mappings.forEach(mapping -> {
//            String from = String.valueOf(mapping.get("from_key"));
//            String to = String.valueOf(mapping.get("to_key"));
//            result.put(to, map.get(from));
//        });
//        return result;
//    }
    public static Map<String, Object> transfer(Map<String, Object> map, List<ExcelSourceTypeMapping> mappings) {
        Map<String, Object> result = new HashMap<>();
        mappings.forEach(mapping -> {
            String from = String.valueOf(mapping.getFromKey());
            String to = String.valueOf(mapping.getToKey());
            result.put(to, map.get(from));
        });
        return result;
    }
}
